<template>
  <i-frame :src="url"/>
</template>

<script>
import { getToken } from '@/utils/auth'
import { getBiViewUrl } from '@/api/tool/jimu'
import iFrame from "@/components/iFrame/index.vue"

export default {
  name: 'ReportView',
  components: {
    iFrame
  },
  data() {
    return {
      url: ''
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      getBiViewUrl().then(res => {
        const reportId = this.$route.path.substring(this.$route.path.lastIndexOf("/") + 1)
        this.url = res + "/" + reportId + "?token=Bearer " + getToken()
      }).catch(error => {
        console.error('获取报表URL失败:', error)
        this.$message.error('报表加载失败，请稍后重试')
      })
    }
  }
}
</script>